package com.ztstech.ali_vod_video.alivideo.bean;


import android.text.TextUtils;

import com.ztstech.ali_vod_video.alivideo.base.BaseResponseBean;

import java.util.List;

public class VideoInfoBean extends BaseResponseBean {


    /**
     * response : {"requestId":"118F03E8-70CE-47C1-BFAA-EDEFD6230755","playInfoList":[{"width":1920,"height":1080,"size":18880320,"playURL":"https://outin-152ef204544711e9b77300163e1c8a9c.oss-cn-shanghai.aliyuncs.com/sv/179257ea-16a632c7045/179257ea-16a632c7045.mp4?Expires=1557109937&OSSAccessKeyId=LTAItL9Co9nUDU5r&Signature=ycFY3bCyUOkvydM7%2FOVBlBXa2ys%3D","bitrate":"20522.09","definition":"OD","duration":"7.36","format":"mp4","fps":"25","encrypt":0,"plaintext":null,"complexity":null,"streamType":"video","rand":null,"jobId":"fb3e82d904a243f0891b9806abcd464802","preprocessStatus":"UnPreprocess","watermarkId":null,"status":"Normal","creationTime":"2019-04-28T09:00:17Z","modificationTime":"2019-04-28T09:00:17Z","encryptType":null,"narrowBandType":"0"}],"videoBase":{"outputType":"oss","coverURL":"http://outin-152ef204544711e9b77300163e1c8a9c.oss-cn-shanghai.aliyuncs.com/fb3e82d904a243f0891b9806abcd4648/snapshots/9f005e461c504a6dac451296362a8c5c-00001.jpg?Expires=1557109937&OSSAccessKeyId=LTAItL9Co9nUDU5r&Signature=A2TyKJ7Uz4ja%2BaValaMZ5bjicpc%3D","duration":"7.36","status":"Normal","title":"哈哈哈","videoId":"fb3e82d904a243f0891b9806abcd4648","mediaType":"video","creationTime":"2019-04-28T09:00:17Z","transcodeMode":"NoTranscode","thumbnailList":[]}}
     * status : 0
     */

    public ResponseBean data;

    /**
     * 播放地址
     * @return
     */
    public String getPlayUrl(){
        if (data == null || data.playInfoList.size() == 0 || data.playInfoList == null || data.playInfoList.isEmpty()){
            return "";
        }
        return data.playInfoList.get(0).playURL;
    }

    /**
     * 文件大小
     * @return
     */
    public String getFileSize() {
        if (data == null || data.playInfoList.size() == 0 || data.playInfoList == null || data.playInfoList.isEmpty()){
            return "0";
        }
        return ""+data.playInfoList.get(0).size;
    }


    /**
     * 播放超清地址
     * @return
     */
    public String getPlayUrlByDefinition(String definition){
        if (data == null || data.playInfoList.size() == 0 || data.playInfoList == null || data.playInfoList.isEmpty()){
            return "";
        }
        for(int i = 0; i < data.playInfoList.size(); i++){
            if(TextUtils.equals(definition, data.playInfoList.get(i).definition)){
                return data.playInfoList.get(i).playURL;
            }
        }
        return data.playInfoList.get(0).playURL;
    }

    /**
     * 超清文件大小
     * @return
     */
    public String getFileSizeByDefinition(String definition) {
        if (data == null || data.playInfoList.size() == 0 || data.playInfoList == null || data.playInfoList.isEmpty()){
            return "0";
        }
        for(int i = 0; i < data.playInfoList.size(); i++){
            if(TextUtils.equals(definition, data.playInfoList.get(i).definition)){
                return ""+data.playInfoList.get(i).size;
            }
        }
        return ""+data.playInfoList.get(0).size;
    }


    /**
     * 封面图
     * @return
     */
    public String getCoverUrl() {
        if (data == null || data.videoBase==null){
            return "";
        }
        return ""+data.videoBase.coverURL;
    }

    public static class ResponseBean {
        /**
         * requestId : 118F03E8-70CE-47C1-BFAA-EDEFD6230755
         * playInfoList : [{"width":1920,"height":1080,"size":18880320,"playURL":"https://outin-152ef204544711e9b77300163e1c8a9c.oss-cn-shanghai.aliyuncs.com/sv/179257ea-16a632c7045/179257ea-16a632c7045.mp4?Expires=1557109937&OSSAccessKeyId=LTAItL9Co9nUDU5r&Signature=ycFY3bCyUOkvydM7%2FOVBlBXa2ys%3D","bitrate":"20522.09","definition":"OD","duration":"7.36","format":"mp4","fps":"25","encrypt":0,"plaintext":null,"complexity":null,"streamType":"video","rand":null,"jobId":"fb3e82d904a243f0891b9806abcd464802","preprocessStatus":"UnPreprocess","watermarkId":null,"status":"Normal","creationTime":"2019-04-28T09:00:17Z","modificationTime":"2019-04-28T09:00:17Z","encryptType":null,"narrowBandType":"0"}]
         * videoBase : {"outputType":"oss","coverURL":"http://outin-152ef204544711e9b77300163e1c8a9c.oss-cn-shanghai.aliyuncs.com/fb3e82d904a243f0891b9806abcd4648/snapshots/9f005e461c504a6dac451296362a8c5c-00001.jpg?Expires=1557109937&OSSAccessKeyId=LTAItL9Co9nUDU5r&Signature=A2TyKJ7Uz4ja%2BaValaMZ5bjicpc%3D","duration":"7.36","status":"Normal","title":"哈哈哈","videoId":"fb3e82d904a243f0891b9806abcd4648","mediaType":"video","creationTime":"2019-04-28T09:00:17Z","transcodeMode":"NoTranscode","thumbnailList":[]}
         */

        public String requestId;
        public VideoBaseBean videoBase;
        public List<PlayInfoListBean> playInfoList;

        public static class VideoBaseBean {
            /**
             * outputType : oss
             * coverURL : http://outin-152ef204544711e9b77300163e1c8a9c.oss-cn-shanghai.aliyuncs.com/fb3e82d904a243f0891b9806abcd4648/snapshots/9f005e461c504a6dac451296362a8c5c-00001.jpg?Expires=1557109937&OSSAccessKeyId=LTAItL9Co9nUDU5r&Signature=A2TyKJ7Uz4ja%2BaValaMZ5bjicpc%3D
             * duration : 7.36
             * status : Normal
             * title : 哈哈哈
             * videoId : fb3e82d904a243f0891b9806abcd4648
             * mediaType : video
             * creationTime : 2019-04-28T09:00:17Z
             * transcodeMode : NoTranscode
             * thumbnailList : []
             */

            public String outputType;
            public String coverURL;
            public String duration;
            public String status;
            public String title;
            public String videoId;
            public String mediaType;
            public String creationTime;
            public String transcodeMode;
            public List<?> thumbnailList;
        }

        public static class PlayInfoListBean {
            /**
             * width : 1920
             * height : 1080
             * size : 18880320
             * playURL : https://outin-152ef204544711e9b77300163e1c8a9c.oss-cn-shanghai.aliyuncs.com/sv/179257ea-16a632c7045/179257ea-16a632c7045.mp4?Expires=1557109937&OSSAccessKeyId=LTAItL9Co9nUDU5r&Signature=ycFY3bCyUOkvydM7%2FOVBlBXa2ys%3D
             * bitrate : 20522.09
             * definition : OD
             * duration : 7.36
             * format : mp4
             * fps : 25
             * encrypt : 0
             * plaintext : null
             * complexity : null
             * streamType : video
             * rand : null
             * jobId : fb3e82d904a243f0891b9806abcd464802
             * preprocessStatus : UnPreprocess
             * watermarkId : null
             * status : Normal
             * creationTime : 2019-04-28T09:00:17Z
             * modificationTime : 2019-04-28T09:00:17Z
             * encryptType : null
             * narrowBandType : 0
             */

            public int width;
            public int height;
            public int size;
            public String playURL;
            public String bitrate;
            public String definition;
            public String duration;
            public String format;
            public String fps;
            public int encrypt;
            public Object plaintext;
            public Object complexity;
            public String streamType;
            public Object rand;
            public String jobId;
            public String preprocessStatus;
            public Object watermarkId;
            public String status;
            public String creationTime;
            public String modificationTime;
            public Object encryptType;
            public String narrowBandType;
        }
    }
}
